<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>指令</title>
</head>
<body>
  <div ng-app="myApp" id="ng-app">
    <my-title></my-title>
    <my-title2></my-title2>
    <div my-title></div>
    <div class="my-title"></div>
    <!-- directive: my-title -->
  </div>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.min.js"></script>
  <script>
    var app = angular.module('myApp', [])
    app.directive('myTitle', function() {
      return {
        restrict: 'EACM', // E=元素element A=Attribute C=class M=comment
        replace : true, // M 时需要设置
        template: '<h1>自定义指令，感觉像vue组件？</h1>'
      }
    }).directive('myTitle2', function() {
      return {
        restrict: '',
        template: '<h1>自定义指令，感觉像vue组件</h1>'
      }
    })
    console.log(app)
  </script>
</body>
</html>
